<template>
    <div>Electron App</div>
    <button @click="onTest">测试串口</button>
</template>

<script setup lang="ts">

const onTest = async () => {
    const sp = window.serialPort;
    const ps = sp.availablePorts();
    console.log(ps);
    for (const name of ps) {
        await sp.open3(name, 115200, () => {});
        await sp.write(Uint8Array.from([1,2,3]));
        await sp.close();
    }
}

</script>


